/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.esoft;

import java.io.UnsupportedEncodingException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.restlet.Restlet;
import org.restlet.data.CharacterSet;
import org.restlet.data.Language;
import org.restlet.data.MediaType;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.resource.StringRepresentation;

 public class HelloRestlet extends Restlet {  
   
     @Override  
     public void handle(Request request, Response response) {  
        try {
            //SpringContext springContext = new SpringContext(getContext());
            //springContext.getPropertyConfigRefs().add("war://config/database.properties");
            

            // get value of 'name' url fragment, using pattern '/hello/{name}'
            String name = (String) request.getAttributes().get("name");
            name = new String(name.getBytes("gb2312"), "utf-8");
            StringRepresentation representation = new StringRepresentation("欧大鹏,敏敏,容儿!", MediaType.TEXT_PLAIN, Language.ALL, CharacterSet.UTF_8);
            // send simple string as response to client
            response.setEntity(representation);
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(HelloRestlet.class.getName()).log(Level.SEVERE, null, ex);
        }
        
     }  

   }
